﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using eeenno.ReaderEngine;
using eeenno.ReaderEngine.Utilities;

namespace eeenno.SpeeedReaderUI.Forms
{
    public partial class SettingsConnectivityForm : Form
    {
        public SettingsConnectivityForm()
        {
            InitializeComponent();
            LoadSettings();
        }
        public void LoadSettings()
        {
            comboBox_download_size.Text = Settings.download_size + " Articles";
            checkBox_download_images.Checked = Settings.download_images;
            checkBox_roaming.Checked = Settings.data_while_roaming_enabled;
            if (SpeeedReader.DoesCacheExist())
            {
                checkBox_offline.Enabled = true;
                checkBox_offline.Checked = Settings.offline_mode_enabled;
            }
            else
            {
                checkBox_offline.Checked = checkBox_offline.Enabled = false;
            }
        }

        private void menuItem_save_Click(object sender, EventArgs e)
        {
            Settings.download_size = int.Parse(comboBox_download_size.Text.Split(' ')[0]);           
            Settings.download_images = checkBox_download_images.Checked;
            Settings.offline_mode_enabled = checkBox_offline.Checked;
            Settings.data_while_roaming_enabled = checkBox_roaming.Checked;
            Settings.WriteSettings();
            DialogResult = DialogResult.OK;
        }

        private void menuItem_cancel_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
        }

    }
}